function a(a) {
    var t = !0;
    return 11 != a.length && (t = !1), /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/.test(a) || (t = !1), 
    t;
}

var t = require("../../utils/api.js"), e = require("../../wxParse/wxParse.js"), n = getApp();

Page({
    data: {
        shop_name: "",
        name: "",
        phone: "",
        comment: "",
        footer: [],
        carnum: wx.getStorageSync("cartnum")
    },
    onLoad: function(a) {
        var o = this;
        wx.setNavigationBarColor({
            frontColor: wx.getStorageSync("basic").topcolor,
            backgroundColor: wx.getStorageSync("basic").topbg
        });
        var r = getCurrentPages(), s = (r[r.length - 1], r[r.length - 2].data);
        console.log(s), 1 == s.supplier && wx.showModal({
            title: "提示",
            content: "你已经是供应商，无须重复申请",
            showCancel: !1,
            success: function(a) {
                a.confirm && wx.reLaunch({
                    url: "/pages/personal/personal"
                });
            }
        }), t.GetApplySupplierSet({
            openid: n.globalData.openid
        }).then(function(a) {
            0 == a.errno && (o.setData({
                apply_supplier_img: a.data.apply_supplier_img.value,
                next_data: a.data.apply_supplier_text.value
            }), e.wxParse("article", "html", a.data.apply_supplier_img.value, o, 5));
        });
    },
    shop_nameInput: function(a) {
        this.setData({
            shop_name: a.detail.value
        });
    },
    nameInput: function(a) {
        this.setData({
            name: a.detail.value
        });
    },
    phoneInput: function(a) {
        this.setData({
            phone: a.detail.value
        });
    },
    commentInput: function(a) {
        this.setData({
            comment: a.detail.value
        });
    },
    submit: function(e) {
        console.log();
        var o = this.data.shop_name, r = this.data.name, s = this.data.phone, i = this.data.comment;
        if ("" == o || void 0 == o) return wx.showToast({
            title: "请输入供应商名称",
            icon: "none"
        }), !1;
        if ("" == r || void 0 == r) return wx.showToast({
            title: "请输入负责人名称",
            icon: "none"
        }), !1;
        if ("" == s || !a(s)) return wx.showToast({
            title: "请输入正确的负责人电话",
            icon: "none"
        }), !1;
        var p = {
            openid: n.globalData.openid,
            shop_name: o,
            name: r,
            phone: s,
            comment: i
        };
        t.ApplaySupplier(p).then(function(a) {
            0 == a.errno ? wx.showToast({
                title: a.message,
                duration: 2e3
            }) : wx.showToast({
                title: a.message,
                icon: "none"
            });
        });
    },
    sites: function(a) {
        var t = this;
        console.log(a);
        var e = a.currentTarget.dataset.data_index, n = t.data.footer;
        "url" == n.params.data[e].type ? wx.reLaunch({
            url: n.params.data[e].url
        }) : "tel" == n.params.data[e].type ? wx.makePhoneCall({
            phoneNumber: n.params.data[e].url
        }) : "out_link" == n.params.data[e].type ? wx.navigateTo({
            url: "/pages/template/out_h5?url=" + n.params.data[e].url
        }) : "app" == n.params.data[e].type && wx.navigateToMiniProgram({
            appId: n.params.data[e].url_name,
            path: n.params.data[e].url,
            envVersion: "develop",
            success: function(a) {}
        });
    }
});